/**
 * useMemo
 */

import { useState, useMemo } from 'react'
import { Button } from 'antd'
import { useTestStore } from 'store/index.js'

function Demo() {
  let [sup, setSup] = useState(5),
    [opp, setOpp] = useState(5),
    [x, setX] = useState(0);

  let ratio = useMemo(() => {
    console.log('----')
    let value = (sup / opp * 100).toFixed(2) + '%'
    return value
  }, [sup, opp])


  return <div>
    <div id='num'>支持数：{sup}</div>
    <div id='num'>反对数：{opp}</div>
    <div id='num'>支持/反对 比率：{ratio}</div>
    <div id='num'>x：{x}</div>
    <Button onClick={() => {
      setSup(sup + 1)
    }}>支持数+1</Button>
    <Button onClick={() => {
      setOpp(opp + 1)
    }}>反对数+1</Button>
    <Button onClick={() => {
      setX(x + 1)
    }}>something</Button>

  </div>
}

export default Demo 